#include <iostream>
#include <string>
#include <openssl/md5.h>

using namespace std;

//g++ -o md5 md5.cpp -lssl -lcrypto

string md5(const string& input) 
{
    unsigned char digest[MD5_DIGEST_LENGTH];
    MD5((const unsigned char*)input.c_str(), input.length(), digest);
    char mdString[33];
    for(int i = 0; i < 16; i++) 
    {
        sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
    }
    return mdString;
}

int main() 
{
    string input = "Hello, World!";
    string md5Result = md5(input);

    std::cout << md5Result << std::endl;

    return 0;
}